/*
 * @(#)DateJsonSerializer.java
 * Date 2013-09-13
 * Version 1.0
 * Author Jim Horner
 * Copyright (c)2012
 */


package us.hornerscorners.lamppost.model;

import java.io.IOException;

import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonProcessingException;

import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;

import org.joda.time.DateTime;

import us.hornerscorners.lamppost.utils.UTCDateUtils;


/**
 * Class description
 *
 *
 * @version        v1.0, 2013-09-13
 * @author         Jim Horner    
 */
public class DateJsonSerializer extends JsonSerializer<DateTime> {

    /**
     * Method description
     *
     *
     * @param value
     * @param jgen
     * @param provider
     *
     * @throws IOException
     * @throws JsonProcessingException
     */
    @Override
    public void serialize(DateTime value, JsonGenerator jgen, SerializerProvider provider)
            throws IOException, JsonProcessingException {

        jgen.writeString(UTCDateUtils.formatDate(value, UTCDateUtils.ISO_DATE_FORMAT));
    }
}
